//
//  UIButton+Extension.swift
//  weibo1
//
//  Created by changhongliang on 2017/7/21.
//  Copyright © 2017年 richinfo. All rights reserved.
//

import UIKit
/*
 便利构造方法有一点注意就是；
 1.一定要用self 调原来的构造方法
 */

extension UIButton {
    
    convenience  init(imageName:String,backImageName:String)
    {
        self.init()
        setImage(UIImage(named:imageName), for: UIControlState.normal)
        setImage(UIImage(named: imageName + "_highlighted"), for:UIControlState.highlighted)
        setBackgroundImage(UIImage(named:backImageName), for: UIControlState.normal)
        setBackgroundImage(UIImage(named:backImageName + "_highlighted"), for: UIControlState.highlighted)
        sizeToFit()
    }
    
   convenience init(title:String, color:UIColor, imageName: String){
    self.init()
    setTitle(title, for: .normal)
    setTitleColor(color, for: .normal)
    setBackgroundImage(UIImage(named:imageName), for: .normal)
    sizeToFit()
    }




}
